.Dd June 23, 2016
.Dt update_dyld_shared_cache 1
.Os Darwin
.Sh NAME
.Nm update_dyld_shared_cache
.Nd "Updates dyld's shared cache"
.Sh SYNOPSIS
.Nm
.Op Fl root Ar directory 
.Op Fl overlay Ar directory 
.Op Fl arch Ar arch 
.Op Fl force 
.Op Fl debug
.Op Fl universal_boot
.Op Fl verify
.Sh DESCRIPTION
.Nm update_dyld_shared_cache
ensures that dyld's shared cache is up-to-date.  This tool is normally
only run by Apple's Installer and Software Update, as they are the only
official ways for OS dylibs to be updated.  But if for some reason you
used another mechanism to alter an OS dylib, you should manually run
.Nm update_dyld_shared_cache . 
.Pp
Note that the new cache does not take effect until the OS is rebooted.  
.Pp
If a safe-boot is
done (booting with shift key held down) the cache is deleted.  
.Pp
The dyld shared cache
is mapped by dyld into a process at launch time. Later, when loading
any mach-o image, dyld will first check if is in the share cache, and if
it is will use that pre-bound version instead of opening, mapping, and binding
the original file.  This results in significant performance improvements to
launch time.
.Pp
.Nm update_dyld_shared_cache
scans the directory /var/db/dyld/shared_region_roots for text files containing paths to
mach-o executables.  The full dependencies of all dylibs required by those executables is
used to determine which libraries are commonly used and should be placed in the
shared cache. If one of the text files contains a path to a dylib, that dylib and its
dependents will be forced into the cache.
.Pp
.Nm update_dyld_shared_cache
builds a separate cache file for each architecture.  The cache files and a readable text
map of the cached are generated to /var/db/dyld.
.Pp
You must be root to run this tool.
.Pp
The options are as follows:
.Bl -tag
.It Fl root Ar directory
This option specifies the root of an OS installation for which dyld's
shared cache should be updated.  This is used by the Installer to update the
dyld shared cache in a partition other than the one you into which you are currently 
booted.  The cache files are created in the var/db/dyld directory of the specified directory.
Note: if you are manually doing this, be sure to run the update_dyld_shared_cache tool
that is in the partition being updated.  This assures the cache format created will
match that expected when booting off that partition. 
.It Fl overlay Ar directory
This option specifies the root of a sparse directory tree.  When building
the dyld shared cache, any corresponding mach-o files in the sparse directory 
will override those in the boot partition.  This is used by Software
Update to build a dyld shared cache for the update that is about to be
installed.  The cache files
are created in the var/db/dyld directory of the specified directory.
.It Fl arch Ar arch
By default 
.Nm update_dyld_shared_cache 
generates cache files for all architecture that the current machine
can execute.  You can override this behavior by specifying one or more -arch options and list
exactly which architectures should have their shared caches updated.
.It Fl force
This option will cause 
.Nm update_dyld_shared_cache
to regenerated the shared cache files even if they appear to be already up-to-date. 
.It Fl debug
This option prints out additional information about the work being done.
.It Fl universal_boot
This option builds caches for all machines.
.It Fl verify
Will regenerate a shared cache in-memory that matches the randomization of the existing shared 
cache file.  Then instead of writing the cache file, it compares the in-memory cache file to
the on disk version and reports any differences.  
.El
.Sh FILES
.Tp
/var/db/dyld/shared_region_roots
directory of text files with paths to mach-o images used to determine what should be in shared cache.
.Sh SEE ALSO
.Xr dyld 1
